package bidhub

class EntryTagLib {
	
	def displayFile = {attrs, body->
	  def user = attrs["user"]
	  def filename = attrs["filename"]
  
	  if(filename){
		def extension = filename.split("\\.")[-1]
		def auctionDir = "bidhub/${user}"
  
		switch(extension.toUpperCase()){
		  case ["JPG", "PNG", "GIF"]:
			   def html = """
			   <p>
				 <img src="${createLinkTo(dir:''+auctionDir,
										  file:''+filename)}"
					  alt="${filename}"
					  title="${filename}"
					  style="width:100%;float:right;" />
			   </p>
			   """
  
			   out << html
			   break
  
		  case "HTML":
			   out << "p>html</p>"
			   break
		  default:
			   out << "<p>file</p>"
			   break
		}
	  }else{
		out << "<!-- no file -->"
	  }
	}
  
  }
  
  
//}
